home *** CD-ROM | disk | FTP | other *** search
Text File | 2001-02-20 | 1.5 KB | 61 lines | [AMAS/AMAP] |
-
- var phiLimit = 0.9 * Math.PI/2;
- phiMin = 20
- phiMax = 80
- //var phi
- //var theta
-
- function TSCameraMove(cameraId,eventId,dragId)
- {
-
- // Get the position of the camera dragger solid
- targetPoint = TSMakePointFromString(TSGetAttribute(cameraId,"targetPoint"));
- // Get the dragger target point
- position = TSMakePointFromString(TSGetAttribute(dragId,"targetPoint"));
-
- // Create the vector between the camera and the target point ( in spherical coordinates )
-
- var sphericCoords = TSVectorToSphericCoords(TSMakeVector(targetPoint,position))
-
- // Compute the current rotation angles
-
- switch (eventId)
- {
- case "arrowRight":
- case "padRight":
- sphericCoords.theta += TSDegToRad(10)
- break
-
- case "arrowLeft":
- case "padLeft":
- sphericCoords.theta -= TSDegToRad(10)
- break
-
- case "arrowUp":
- case "padUp":
- newPhi = sphericCoords.phi + TSDegToRad(10)
- if (newPhi < phiLimit && newPhi < TSDegToRad(phiMax)) {
- sphericCoords.phi = newPhi;
- }
- break
-
- case "arrowDown":
- case "padDown":
- newPhi = sphericCoords.phi - TSDegToRad(10)
- if (newPhi > -phiLimit && newPhi > TSDegToRad(phiMin)) {
- sphericCoords.phi = newPhi;
- }
- break
-
- }
-
- position=TSSphericCoordsToVector(sphericCoords);
- position=TSPointTranslate(position,targetPoint.x,targetPoint.y,targetPoint.z);
- // Move the camera dragger at the new location
- TSUpdateNodeAttribute("dragCamera","targetPoint",TSMakeStringFromPoint(position))
- return sphericCoords;
- }
-
-
-
-